#pragma once

class Label;
class Label;
class Variable;
class Font;

class ConsoleHud:
	public IShellOutput,
	public IKeyboardDriver,
	public IHud
{
public:
	ConsoleHud();
	~ConsoleHud();

	/*-IHud---------------------------------------------------------------------*/
	void			OnHudUpdate();
	void			OnHudRender();

	/*-IKeyboardDriver----------------------------------------------------------*/
	void			OnKeyboardAction();

	/*--------------------------------------------------------------------------*/

	void			Print(const std::string& message);
	void			Clear();

private:
	/*--------------------------------------------------------------------------*/
	bool			key_historyUp;
	bool			key_historyDown;
	bool			key_codeSuggest;
	bool			key_enter;
	bool			key_pageUp;
	bool			key_pageDown;
	/*--------------------------------------------------------------------------*/

	void			CheckTilda();
	void			ParseIncomingData();
	void			TrimLines();
	void			DrawConsole();
	void			HandleKeys();

	std::list<Label> m_lines;		//!<Bufor linijek konsolowych

	std::list<std::string>				m_inputHistory;	//!<Historia
	std::list<std::string>::iterator	m_inputHistorySelection; //!<Ostatnio brany item ze stacka

	uint m_deltaLines;				//!<Pominięcie tylu najnowszych linijek
	uint m_linesOnScreen;			//!<Ilość linijek na ekranie

	std::string m_inputContent;				//!<Zawartość aktualnego wejścia
	std::string m_suggestions;

	Variable* var_console_enabled;

	/*-Layout-------------------------------------------------------------------*/
	Font* res_contentFont;
	Font* res_codesuggests_font;

	/*--------------------------------------------------------------------------*/
	std::streambuf* m_coutBackup;
	std::streambuf* m_cerrBackup;

	/*--------------------------------------------------------------------------*/
	const Material* m_backgroundMaterial;
};

namespace sh
{
void print_float(float message);
void print_int(int message);
void print_string(const std::string& message);
void clear();
};